﻿using System.Collections.Generic;
using System.Linq;
using Melee.DataContract.Views;
using Melee.Infrastructure.Configuration;
using Melee.Models.Entity;

namespace Melee.DataContract.Extension
{
    public static class MapExtensionMethod
    {
        public static IEnumerable<MapView> ConvertToMapView(this IEnumerable<Map> maps)
        {
            return maps.Select(m => new MapView
            {
                Id = m.Id,
                Img = m.Img,
                Name = m.Name,
                X = m.X * ApplicationSettingsFactory.ApplicationSettings.MapWidth,
                Y = m.Y * ApplicationSettingsFactory.ApplicationSettings.MapHeight,
                Areas = m.Areas.ConvertToAreaView(),
                Cities = m.Cities.ConvertToCityViewOfMap(),
                Duplicates = m.Duplicates.ConvertToDuplicateView()
            });
        }
    }
}
